$(function(){
	//加载游戏列表
	loadGames();
	//初始化日期控件
  	$('#bt, #et').datetimepicker({
  		language: 'zh-CN',
	    format: 'yyyy-mm-dd hh:ii:00',
	    autoclose: true,
	    minuteStep: 1,
	    minView: "hour"
	});
	
});

function findAll(serverId){
	$("#reset").click();
	loadDatas(serverId);
}
//查询数据
function loadDatas(serverId){
	//初始化统计图的div
	$("#bloodPoolChange").html("").css({color: "",height: "500px", lineHeight: ""});
	
	//加载房间血池变化统计图
	loadCountCharts(serverId);
	
}

//加载房间血池变化统计图
function loadCountCharts(serverId){
	//房间
	var room = $("#room").val();
	//开始时间
	var begin = $("#begin").val();
	//结束时间
	var end = $("#end").val();
	
	if(room == ""){
		room = serverId;
	}
	
//	alert("room： "+room+"; begin:"+begin+"; end: "+end);
	$.ajax({
		type:"post",
		data: {"serverId": room, "begin":begin, "end":end},
		url:"/admin/roomSet/bloodPoolChanges",
		beforeSend: function(){
			$("#load").css("display","block");
		},
		success: function(msg){
			$("#load").css("display","none");
			var datas = msg.chartDatas;
//			console.log(datas);
			if(datas.length == 0){
				$("#bloodPoolChange").html("没查询到符合条件的数据~").css({color: "red",height: "100px", lineHeight: "100px"});
			}else{
				//加载曲线图
				Morris.Area({
				    element: 'bloodPoolChange',
				    behaveLikeLine: false,
				    gridTextFamily: '微软雅黑',
				    data: datas,
				    xkey: 'x',
				    ykeys: ['y', 'z'],
				    labels: ['血池','血池平衡'],
				    smooth: true, //幅度效果
				    hideHover: true, //滑鼠移出图表时，提示框是否隐藏
				    lineColors: ['#6dc5a3', '#C1C1C1'],
				    parseTime: false,
				    pointSize: 0,
				    lineWidth: 2
				});
			}
		}
	});
}